/*
 * @Author: MiNine
 * @Date: 2020-09-18 17:28:29
 * @LastEditors: MiNine
 * @LastEditTime: 2020-09-21 09:50:11
 * @Description: 保险订单
 */

const {
  Schema,
  model
} = require('mongoose').set('useFindAndModify', false);
const dayjs = require('dayjs');

const insureOrderSchema = new Schema({
  //销售员id
  adminId: {
    type: Schema.Types.ObjectId,
    ref: 'Admin'
  },
  //客户id
  clientId: {
    type: Schema.Types.ObjectId,
    ref: 'Client'
  },
  //保险产品名称
  productName: String,
  //支付金额
  payPrice: String,
  //赔付金额
  compensation: String,
  //到期时间
  dueTime: String,
  //生效时间
  inForceTime: String,
  //订单状态
  status: {
    type: Number,
    default: 1
    /*
      0 : 退保
      1 : 待支付
      2 : 待生效
      3 : 生效状态
      4 : 过期状态
      5 : 退保过程中(待管理员确定)
    */
  },
  //下单时间
  payTime: {
    type: String,
    default: dayjs().format('YYYY-MM-DD HH:mm:ss')
  }

}, {
  versionKey: false
})

const InsureOrder = model('InsureOrder', insureOrderSchema);

module.exports.InsureOrder = InsureOrder;